package com.yunxi.core.web;

public class ResponseUtil {

    public static ApiResult ok() {
        ApiResult rb = new ApiResult();
        rb.setCode(200);
        rb.setMsg("成功");
        return rb;
    }

    public static ApiResult ok(Object data) {
        ApiResult obj = new ApiResult();
        obj.setCode(200);
        obj.setMsg("成功");
        obj.setData(data);
        return obj;
    }

    public static ApiResult ok(String msg, Object data) {
        ApiResult obj = new ApiResult();
        obj.setCode(200);
        obj.setMsg(msg);
        obj.setData(data);
        return obj;
    }

    public static ApiResult fail() {
        ApiResult obj = new ApiResult();
        obj.setCode(-1);
        obj.setMsg("错误");
        return obj;
    }

    public static ApiResult fail(int code, String msg) {
        ApiResult obj = new ApiResult();
        obj.setCode(code);
        obj.setMsg(msg);
        return obj;
    }

    public static ApiResult fail(int code, String msg ,  Object data) {
        ApiResult obj = new ApiResult();
        obj.setCode(code);
        obj.setMsg(msg);
        obj.setData(data);
        return obj;
    }

    public static ApiResult fail401() {
        return fail(401, "请登录");
    }

    public static ApiResult unlogin(){
        return fail401();
    }

    public static ApiResult fail402() {
        return fail(402, "参数不对");
    }

    public static ApiResult badArgument(){
        return fail402();
    }

    public static ApiResult fail403() {
        return fail(403, "参数值不对");
    }

    public static ApiResult badArgumentValue(){
        return fail403();
    }

    public static ApiResult fail501() {
        return fail(501, "业务不支持");
    }

    public static ApiResult unsupport(){
        return fail501();
    }

    public static ApiResult fail502() {
        return fail(502, "系统内部错误");
    }

    public static ApiResult fail900() {
        return fail(900, "服务未启动成功");
    }

    public static ApiResult serious(){
        return fail502();
    }


}

